package com.IO.FileInputStream;

import java.io.FileInputStream;
import java.io.IOException;

/**
 * name：zhangwang
 * time：2025/3/11 13:27
 */
public class Test2 {
    public static void main(String[] args) throws IOException {
        //创建字节输出流对象
        FileInputStream fileInputStream = new FileInputStream("a.txt");
        //2.读数据：一次读一个字节数组
        byte[] bt = new byte[1024];
        int b;//记录每次读到的数据个数
        /**
         * b = fileInputStream.read(bt)读1024个数据，把数据存储到数组中，并把真实读的数据个数赋值给b
         */
        while ((b = fileInputStream.read(bt)) != -1) {
            System.out.println(new String(bt,0, b));
        }
        //3.释放资源
        fileInputStream.close();
    }
}
